package org.example.springboot.controller;

import jakarta.annotation.Resource;
import org.example.springboot.common.Result;
import org.example.springboot.entity.BD;
import org.example.springboot.service.ShowService;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@CrossOrigin
@RestController
@RequestMapping("/show")

public class ShowController {

    @Resource
    private ShowService showService;


    @GetMapping("/hello")
    public Result getMessage() {
        List<BD> allData = showService.getAllData();
        return Result.success(allData);
    }

    /**
     * 小说分类书籍数量排行
     */
    @GetMapping("/bookSortNumber")
    public Result getBookSortNumber() {
        List<Map<String, Object>> allData = showService.getBookSortNumber();
        return Result.success(allData);
    }

    // 接口2: 小说分类占比（按一级分类）
    @GetMapping("/category/percentage")
    public Result categoryPercentage() {
        List<Map<String, Object>> data = showService.getCategoryPercentage();
        return Result.success(data);
    }

    // 接口3: 小说分类人气趋势图（按一级分类，取总人气值）
    @GetMapping("/category/popularity-ranking")
    public Result categoryPopularityRanking() {
        List<Map<String, Object>> data = showService.getCategoryPopularityRanking();
        return Result.success(data);
    }

    // 接口4: 小说人气与分类关系雷达图（结构化数据）
    @GetMapping("/category/popularity-relation")
    public Result categoryPopularityRelation() {
        Map<String, Object> result = showService.getCategoryPopularityRelation();
        return Result.success(result);
    }


    // 接口5: 前12名小说字数排行
    @GetMapping("/word-count-top12")
    public Result wordCountTop12() {
        List<Map<String, Object>> data = showService.getWordCountTop12();
        return Result.success(data);
    }

    // 接口6: 前12名小说人气排行
    @GetMapping("/popularity-top12")
    public Result popularityTop12() {
        List<Map<String, Object>> data = showService.getPopularityTop12();
        return Result.success(data);
    }

}